root_dir=$(pwd)

#for arch in V100 X86 VGNU
#for arch in X86
for arch in X86
do
    cd $root_dir/mongoose
    make clean
    make ARCH_VERSION=$arch -j8

    cd $root_dir/app_device
    make clean
    make ARCH_VERSION=$arch TARGET=remote_device_$arch -j8 2>err.log

    if [ $? -ne 0 ]; then
        echo "build app_d failed"
        cat err.log | grep error
        exit 0
    fi

    cd $root_dir/app_proxy
    make clean
    make ARCH_VERSION=$arch TARGET=remote_server_$arch -j8  2>err.log

    if [ $? -ne 0 ]; then
        echo "build app_s failed"
        cat err.log | grep error
        exit 0
    fi

done
cd $root_dir
cp -vf app_d/remote_device_V100 /nfsroot/
